package model;

import model.spring.EmailonlyAddress;
import model.spring.PostalAddress;
import view.decorator.FlagDecorator;
import junit.framework.TestCase;

public class ModelTest extends TestCase {
	private EmailonlyAddress addr1;
	private PostalAddress addr2;
	
	protected void setUp() throws Exception {
		super.setUp();
		
		addr1 = new EmailonlyAddress();
		addr1.setEmailaddress("info@mail-1.de");
		addr1.setName("Hans");
		
		addr2 = new PostalAddress();
		addr2.setEmailaddress("peter@mail-1.de");
		addr2.setName("Peter");
		addr2.setStreet("Ahornweg");
		addr2.setHousenumber("13");
		addr2.setZipcode("67112");
		addr2.setCity("Mutterstadt");
	}

	protected void tearDown() throws Exception {
		super.tearDown();
		
		testWithDecorator();
		testWithoutDecorator();
	}

	public void testWithDecorator() {
		assertFalse("Addresse mit Dirty-Flag", addr1.toString().startsWith(">"));
		assertFalse("Addresse mit Dirty-Flag", addr2.toString().startsWith(">"));
		
		FlagDecorator addr1decorated = new FlagDecorator(addr1);
		FlagDecorator addr2decorated = new FlagDecorator(addr2);
		
		assertTrue("Addresse mit Dirty-Flag", addr1decorated.toString().startsWith(">"));
		assertTrue("Addresse mit Dirty-Flag", addr2decorated.toString().startsWith(">"));
	}

	public void testWithoutDecorator() {
		assertFalse("Addresse mit Dirty-Flag", addr1.toString().startsWith(">"));
		assertFalse("Addresse mit Dirty-Flag", addr2.toString().startsWith(">"));
	}
}
